package com.gx.smart.building.ui.common.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.gx.smart.base.BaseAdapter;
import com.gx.smart.building.R;

/**
 * @author xiaosy
 * @create 2019-11-20
 * @Describe
 **/
public class ImageAdapter extends BaseAdapter<String, ImageAdapter.ViewHolder> {

    public ImageAdapter(Context context) {
        super(context);
    }

    @Override
    protected int onBindLayout() {
        return R.layout.item_image_layout;
    }

    @Override
    protected ViewHolder onCreateHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected void onBindData(ViewHolder holder, String item, int position) {
        String url = item;
        Glide.with(mContext).load(url)
                .placeholder(R.mipmap.ic_default)
                .into(holder.imageView);
    }

    protected class ViewHolder extends RecyclerView.ViewHolder {
        private final ImageView imageView;

        public ViewHolder(View view) {
            super(view);
            imageView = view.findViewById(R.id.image);
        }
    }
}
